-
Notifications
You must be signed in to change notification settings - Fork 431
feat(clerk-js,ui,shared): Add Safari ITP decorateUrl workaround to setActive
#7623
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…ack for Safari ITP fix Why: Safari's Intelligent Tracking Prevention (ITP) caps cookies set via fetch/XHR to 7 days. When users switched from redirectUrl to the navigate callback pattern, the existing ITP workaround (via /v1/client/touch endpoint) stopped working because the touch endpoint logic only ran in the redirectUrl branch. What changed: - Added decorateUrl function to the navigate callback that wraps URLs with the touch endpoint when Safari ITP fix is needed (client.isEligibleForTouch()) - Updated SetActiveNavigate type signature to include decorateUrl parameter - Added dev-mode warning when decorateUrl is not called but ITP fix is needed - Updated all internal usages in SignIn, SignUp, and SessionTasks components to pass decorateUrl through navigateOnSetActive Context: The decorateUrl may return an external URL (https://...) when ITP fix is needed, requiring window.location.href instead of client-side navigation. This pattern is documented in the type definitions.
Why: The Safari ITP fix (decorateUrl in setActive) was added without integration test coverage. These tests ensure the touch endpoint navigation works correctly when the client cookie is close to expiration. What changed: - Added 4 tests covering the Safari ITP workaround flow - Tests verify touch endpoint is called when cookie expires within 8 days - Tests verify decorateUrl behavior with mocked isEligibleForTouch
🦋 Changeset detectedLatest commit: c199933 The changes in this PR will be included in the next version bump. This PR includes changesets to release 20 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughIntroduces a DecorateUrl callback into Clerk's setActive navigation flow and a public DecorateUrl type. Propagates decorateUrl through core clerk logic, shared types, SignIn/SignUp/SessionTasks contexts, and UI components. Runtime behavior: when eligible for Safari ITP touch, decorateUrl can wrap redirect URLs using the /v1/client/touch flow and may trigger full-page navigation for absolute decorated URLs. Adds unit tests and an integration Playwright suite simulating Safari ITP cookie scenarios. Possibly related PRs
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
@clerk/agent-toolkit
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/dev-cli
@clerk/expo
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/localizations
@clerk/nextjs
@clerk/nuxt
@clerk/react
@clerk/react-router
@clerk/shared
@clerk/tanstack-react-start
@clerk/testing
@clerk/ui
@clerk/upgrade
@clerk/vue
commit: |
brkalow
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implementation looks good! Does the warning fire reliably? I suppose yes, we're mostly safe because Clerk doesn't unmount / get cleaned up on navigations, unless it's a full navigation.
| 'Clerk: The navigate callback in setActive() did not call decorateUrl(). ' + | ||
| 'In Safari, sessions may be limited to 7 days due to Intelligent Tracking Prevention (ITP). ' + | ||
| 'Use decorateUrl() to wrap your destination URL to enable the ITP workaround. ' + | ||
| 'Learn more: https://clerk.com/docs/troubleshooting/safari-itp', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙃 this link leads to 404
# Conflicts: # packages/ui/src/components/SignIn/handleCombinedFlowTransfer.ts
Why:
The previous check `decoratedUrl.startsWith('https://')` incorrectly triggered full page navigation for any absolute https:// redirect URL, even when decorateUrl didn't modify it. This caused unnecessary full page navigations in non-ITP scenarios.
What changed:
Now checks if decorateUrl actually modified the URL (`decoratedUrl !== redirectUrl`) AND that the result is an absolute http/https URL. This ensures full page navigation only happens when Safari ITP decoration is applied.
Description
Why:
Safari's Intelligent Tracking Prevention (ITP) caps cookies set via fetch/XHR
to 7 days. When users switched from redirectUrl to the navigate callback pattern,
the existing ITP workaround (via /v1/client/touch endpoint) stopped working
because the touch endpoint logic only ran in the redirectUrl branch.
What changed:
touch endpoint when Safari ITP fix is needed (client.isEligibleForTouch())
to pass decorateUrl through navigateOnSetActive
Context:
The decorateUrl may return an external URL (https://...) when ITP fix is needed,
requiring window.location.href instead of client-side navigation. This pattern
is documented in the type definitions.
Checklist
pnpm testruns as expected.pnpm buildruns as expected.Type of change
Summary by CodeRabbit
New Features
Tests
✏️ Tip: You can customize this high-level summary in your review settings.